#include <iostream>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <set>
#include <unordered_set>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const int INF=0x3f3f3f3f;
int m[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};

int main()
{
	int a[12]={2,0,2,2};
	int idx=4;
	int ans=0;
	for(int i=1;i<=12;i++)
	{
		if(i<10)
		{
			a[idx]=0;
			idx++;
			a[idx]=i;
			idx++;
		}
		else
		{
		   	  a[idx++]=i/10;
		   	  a[idx++]=i%10;
		}
		for(int j=1;j<=m[i];j++)
		{
			if(j<10)
		   {
			a[idx++]=0;
			a[idx++]=j;
		   }
		   else
		   {
		   	  a[idx++]=j/10;
		   	  a[idx++]=j%10;
		   }
		   for(int k=0;k+2<idx;k++)
		   {
		   	    if(a[k]+1==a[k+1] && a[k+1]+1==a[k+2]) 
		   	    {
		   	    	ans++;
		   	    	break;
				}
		   }
		   idx-=2;
		}
		idx-=2;
	}
	cout<<ans;

	return 0;
}

